package com.matou.auth.social.weixin.config;

import com.matou.auth.social.properties.SocialProperties;
import com.matou.auth.social.properties.WeChatProperties;
import me.zhyd.oauth.request.AuthWeChatMpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthWeChatOpenRequest;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
/**
 * @author chenmiao0212
 * @date 2021/6/12 22:42
 */
@Configuration
public class AuthWeChatConfig {

   @Autowired
   private SocialProperties socialProperties;

    @Bean
    public AuthRequest getAuthRequest() {
        WeChatProperties wechat = socialProperties.getWechat();
        return new AuthWeChatOpenRequest(AuthConfig.builder()
                .clientId(wechat.getClientId())
                .clientSecret(wechat.getClientSecret())
                .redirectUri(wechat.getRedirectUri())
                .build());
    }
}
